package com.lagou.filter;

import com.lagou.constant.DubboConstant;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

@Activate(group = {CommonConstants.PROVIDER})
public class TransportIPFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        String ipAddr = RpcContext.getContext().getAttachment(DubboConstant.IP_KEY);
        System.out.println("实际请求ip:" + ipAddr);
        Result invoke = invoker.invoke(invocation);
        return invoke;
    }
}
